/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.fatec.main;

import br.fatec.aluno.Aluno;
import br.fatec.aluno.Avaliacao;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
/**
 *
 * @author Kenji
 */
public class MainMostrarAluno {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        EntityManagerFactory fabricaMotores = Persistence.createEntityManagerFactory("escolaModelo");
        
        EntityManager motor = fabricaMotores.createEntityManager();
        
        Query pesquisa = motor.createQuery("select c from Aluno c join c.avaliacoes v");
        Query pesquisa2 = motor.createQuery("select v from Avaliacao v");
        
        List<Aluno> listaAlunos = pesquisa.getResultList();
        List<Avaliacao> listaAvalia = pesquisa2.getResultList();
        
        for(Avaliacao avaliaTmp : listaAvalia){
            
            for(Aluno alunoTmp : listaAlunos){
                System.out.println("RA: " + alunoTmp.getRa());
                System.out.println("Nome: " + alunoTmp.getNome());
                System.out.println("Idade: " + alunoTmp.getIdade());
                System.out.println("Id: " + avaliaTmp.getId());
                System.out.println("Materia: " + avaliaTmp.getMateria());
                System.out.println("Nota: " + avaliaTmp.getNota());
            }
        }
    }
}
